$(function(){
	
	$("#sub").click(function(){
		$("#myform").submit();
		
		parent.location.reload();
	});
	getUser();
})

/**
 * 获取Session
 * @returns
 */
function getUser(){
	var url="../../../role/getUserName.action";
	var data=null;
	$.post(url,data,function(mes){
		$("#userId").val(mes.userId);
		$("#photo").attr({"src":"../../../"+mes.userImage});
		$("#userName").val(mes.userName);
		$("#userPwd").val(mes.userPwd);
		$("#userPhone").val(mes.userPhone);
		$("#userEmail").val(mes.userEmail);
		load();
	},"json");
}

layui.use(['form', 'layedit', 'laydate','table'], function(){
  var table = layui.table
  ,laydate = layui.laydate
  ,form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,upload = layui.upload;
 
//普通图片上传
	var uploadInst = upload.render({
		elem: '#userImage'
			,url: '/upload/'
				,auto:0
				,choose: function(obj){
					//预读本地文件示例，不支持ie8
					obj.preview(function(index, file, result){
						$('#photo').attr('src', result); //图片链接（base64）
						$("#photo").css({"width":"50px","height":"50px"});
					});
				}
	});
  
});
function load() {
	 var form = layui.form
	 form.render();
}